//
// Created by ct on 2021/11/4.
//

#ifndef ALGOANDSTRUCT_MYCIRCULARDEQUE_H
#define ALGOANDSTRUCT_MYCIRCULARDEQUE_H

#include <vector>


class MyCircularDeque {
private:
    int K;
public:

    const vector<int> & getV() const {
        return q;
    }

    explicit MyCircularDeque(int k) {
      //  this->q.resize(k);
        this->K = k;
    }

    bool insertFront(int value) {
        if (!isFull()) {
            q.insert(q.begin(), value);
            return true;
        }
        return false;
    }

    bool insertLast(int value) {
        if (!isFull()) {
            q.push_back(value);
            return true;
        }
        return false;


    }

    bool deleteFront() {
        if (!isEmpty()) {
            q.erase(q.begin());
            return true;
        }
        return false;
    }

    bool deleteLast() {
        if (!isEmpty()) {
            q.pop_back();
            return true;
        }
        return false;
    }

    int getFront() {
        if (isEmpty()) {
            return -1;
        }
        return q.front();
    }

    int getRear() {
        if (isEmpty()) {
            return -1;
        }
        return q.back();
    }

    bool isEmpty() {
        return q.empty();
    }

    bool isFull() {
        return q.size() >= K;
    }

    std::vector<int> q;
};

#endif //ALGOANDSTRUCT_MYCIRCULARDEQUE_H
